#include <iostream>
#include <string>
using std::cin; using std::cout; using std::endl; using std::string;

struct Sales_data
{
    std::string isbn() const { return bookNo; }
    Sales_data& combine(const Sales_data&);
    string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
};

Sales_data& Sales_data::combine(const Sales_data &rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

int main()
{
    Sales_data total, trans;
    cin >> total.bookNo >> total.units_sold >> total.revenue;
    cin >> trans.bookNo >> trans.units_sold >> trans.revenue;
    if(trans.isbn() == total.isbn())
        total.combine(trans);
    else
        cout << trans.bookNo << " " << trans.units_sold << " " << trans.revenue << endl;
    cout << total.bookNo << " " << total.units_sold << " " << total.revenue << endl;
    return 0;
}